package com.heima.behavior.controller;

import com.heima.behavior.service.BehaviorService;
import com.heima.model.common.dtos.LikesBehaviorDto;
import com.heima.model.common.dtos.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author Geralt
 * @Date 2024-08-01 9:50
 */
@Slf4j
@RestController
@RequestMapping("/api/v1")
public class BehaviorController {

    @Autowired
    private BehaviorService behaviorService;

    /**
     * 文章点赞
     *
     * @return
     */
    @PostMapping("likes_behavior")
    public ResponseResult likesBehavior(@RequestBody LikesBehaviorDto likesBehaviorDto) {
        log.info("文章点赞的数据是：{}", likesBehaviorDto);
        return behaviorService.likesBehavior(likesBehaviorDto);
    }

    /**
     * 阅读文章
     *
     * @param behaviorDto
     * @return
     */
    @PostMapping("/read_behavior")
    public ResponseResult readBehavior(@RequestBody LikesBehaviorDto behaviorDto) {
        log.info("阅读文章的数据是：{}", behaviorDto);
        return behaviorService.readBehavior(behaviorDto);
    }

    /**
     * 用户不喜欢操作
     * @param behaviorDto
     * @return
     */
    @PostMapping("un_likes_behavior")
    public ResponseResult unLikesBehavior(@RequestBody LikesBehaviorDto behaviorDto) {
        log.info("用户不喜欢的数据是：{}", behaviorDto);
        return behaviorService.unLikesBehavior(behaviorDto);
    }

}
